<template>
  <div class="app-container">
    <a-title @clickPreview="preview" />
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="100px">
      <el-form-item label="任务名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入任务名称"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否里程碑" prop="milestoneFlag" label-width="100px">
        <el-select v-model="queryParams.milestoneFlag" clearable size="small" style="width: 240px">
          <el-option label="是" value="1"></el-option>
          <el-option label="否" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="任务状态" prop="status">
        <el-select v-model="queryParams.status" clearable size="small" style="width: 240px">
          <el-option label="已完成" value="1"></el-option>
          <el-option label="未完成" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="执行人" prop="nickName">
        <el-input
          v-model="queryParams.nickName"
          placeholder="请输入执行人"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="参与人" prop="joinByName">
        <el-input
          v-model="queryParams.joinByName"
          placeholder="请输入参与人"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划开始时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.planStartTime"
          type="daterange"
          range-separator="-"
          value-format="yyyy-MM-dd"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="实际开始时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.actualStartTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="计划结束时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.planEndTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="实际结束时间" label-width="100px">
        <el-date-picker
          v-model="queryParams.actualEndTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          style="width: 240px"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-dropdown trigger="click" @command="handleCommand">
          <el-button type="primary" size="mini" plain>
            导入模板
            <i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item v-hasPermi="['system:taskTemplate:list']" command="a">标准模板</el-dropdown-item>
            <el-dropdown-item command="b">
              <el-upload
                class="upload-demo"
                ref="upload"
                :show-file-list="false"
                :before-upload="beforeUpload"
                action="#"
              >自制模板</el-upload>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出自制模板</el-button>
      </el-col>
    </el-row>
    <el-table
      stripe
      v-loading="loading"
      :data="tableData"
      style="width: 100%;"
      row-key="guid"
      ref="multipleTable"
      default-expand-all
      @selection-change="handleSelectionChange"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
      @select-all="selectAll"
    >
      <el-table-column type="selection" width="55" align="center"></el-table-column>
      <!-- <el-table-column type="index" width="50" label="序号"></el-table-column> -->
      <el-table-column prop="name" label="任务名称" align="left"></el-table-column>
      <el-table-column label="是否里程牌" width="90" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.milestoneFlag=='1'">是</span>
          <span v-else>否</span>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="任务状态" width="80" align="center">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status === '1'" type="success" disable-transitions>已完成</el-tag>
          <el-tag v-else type="info" disable-transitions>未完成</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="计划开始时间" width="165" align="center">
        <template slot-scope="scope">
          <el-date-picker
            v-model="scope.row.planStartTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            @change="changeDate(scope.$index, scope.row)"
          ></el-date-picker>
        </template>
      </el-table-column>
      <el-table-column label="实际开始时间" width="165" align="center">
        <template slot-scope="scope">
          <el-date-picker
            v-model="scope.row.actualStartTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            @change="changeDate(scope.$index, scope.row)"
          ></el-date-picker>
        </template>
      </el-table-column>
      <el-table-column label="计划结束时间" width="165" align="center">
        <template slot-scope="scope">
          <el-date-picker
            v-model="scope.row.planEndTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            @change="changeDate(scope.$index, scope.row)"
          ></el-date-picker>
        </template>
      </el-table-column>
      <el-table-column label="实际结束时间" width="165" align="center">
        <template slot-scope="scope">
          <el-date-picker
            v-model="scope.row.actualEndTime"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            @change="changeDate(scope.$index, scope.row)"
          ></el-date-picker>
        </template>
      </el-table-column>
      <el-table-column prop="nickName" label="执行人" width="100" align="center"></el-table-column>
      <el-table-column prop="joinByName" label="参与人" width="120" align="center"></el-table-column>
      <el-table-column prop="remark" label="备注" align="left" width="150"></el-table-column>
      <el-table-column width="100" label="操作" align="center">
        <template slot-scope="scope">
          <a @click="handleEdit(scope.$index, scope.row)">
            <i class="el-icon-edit aicon"></i>编辑
          </a>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog :title="title" :visible.sync="dialogVisible" width="60%">
      <!-- <div slot="title"></div> -->
      <div class="tabletitle">
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">
                <span class="mustinput">*</span>主任务
              </div>
              <div class="input-content">
                <treeselect
                  placeholder="请选择主任务"
                  v-model="task.taskParentId"
                  :options="taskOptionsChild"
                />
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">
                <span class="mustinput">*</span>任务名称
              </div>
              <div class="input-content">
                <el-input v-model="task.name" placeholder="请输入"></el-input>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">是否里程牌</div>
              <div class="input-content">
                <el-select v-model="task.milestoneFlag" placeholder="请选择">
                  <el-option label="是" value="1"></el-option>
                  <el-option label="否" value="0"></el-option>
                </el-select>
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">任务状态</div>
              <div class="input-content">
                <el-select v-model="task.status" placeholder="请选择">
                  <el-option label="已完成" value="1"></el-option>
                  <el-option label="未完成" value="0"></el-option>
                </el-select>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">计划开始时间</div>
              <div class="input-content">
                <el-date-picker
                  v-model="task.planStartTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                  style="width:100%"
                ></el-date-picker>
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">实际开始时间</div>
              <div class="input-content">
                <el-date-picker
                  v-model="task.actualStartTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                  style="width:100%"
                ></el-date-picker>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">计划结束时间</div>
              <div class="input-content">
                <el-date-picker
                  v-model="task.planEndTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                  style="width:100%"
                ></el-date-picker>
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">实际结束时间</div>
              <div class="input-content">
                <el-date-picker
                  v-model="task.actualEndTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                  style="width:100%"
                ></el-date-picker>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">执行人</div>
              <div class="input-content">
                <el-select
                  v-model="task.executeBy"
                  placeholder="请选择"
                  style="width:100%"
                  :filterable="true"
                >
                  <el-option
                    v-for="item in userList"
                    :key="item.userId"
                    :label="item.nickName"
                    :value="item.userId"
                  ></el-option>
                </el-select>
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="input-wrap">
              <div class="input-label">参与人</div>
              <div class="input-content">
                <el-select
                  v-model="task.joinBy"
                  placeholder="请选择"
                  style="width:100%"
                  :multiple="true"
                  :filterable="true"
                >
                  <el-option
                    v-for="item in userList"
                    :key="item.userId"
                    :label="item.nickName"
                    :value="item.userId"
                  ></el-option>
                </el-select>
              </div>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <div class="input-wrap">
              <div class="input-label">备注</div>
              <div class="input-content">
                <el-input v-model="task.remark" placeholder="请输入" type="textarea" :rows="4"></el-input>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="sumbitTask" :disabled="canClick">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 模板列表 -->
    <el-dialog :visible.sync="openTemplate" width="800px" :show-close="false">
      <el-form :model="formTemplateQuery" label-width="100px">
        <el-row>
          <el-col :span="16">
            <div class="grid-content bg-purple">
              <el-form-item label="模板名称" prop="name">
                <el-input v-model="formTemplateQuery.templateName" placeholder="请输入" />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="4">
            <el-form-item label-width="0px" style="text-align:center">
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="handleQueryTemp"
              >查询</el-button>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label-width="0px">
              <el-button icon="el-icon-refresh" size="mini" @click="resetQueryTemp">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table v-loading="loading" :data="taskTemplateList">
        <el-table-column label="模版名称" align="center" prop="templateName" />
        <el-table-column label="业务类别" align="center" prop="businessCategoryName" />
        <el-table-column label="创建时间" align="center" prop="createTime" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="templateImport(scope.row)"
              icon="el-icon-upload2"
            >导入</el-button>
            <el-button
              size="mini"
              type="text"
              @click="templatePreview(scope.row)"
              icon="el-icon-search"
            >在线预览</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getTemplateList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="openTemplate=false">关 闭</el-button>
      </div>
    </el-dialog>
    <!-- 预览 -->
    <el-dialog :visible.sync="openPreview" width="80%">
      <iframe :src="manualPreviewUrl" frameborder="0" width="100%" height="700px"></iframe>
    </el-dialog>
  </div>
</template>
<script>
import {
  listTask,
  getTask,
  treeTask,
  updateTask,
  addTask,
  exportTask,
  delTask,
  importData,
  importTemplate
} from "@/api/business/task";
import { listTaskTemplate } from "@/api/system/taskTemplate";
import { listAllMember } from "@/api/projectWorkbench/projectList/member";
import { formatDate } from "@/utils";
import aTitle from "@/components/Title";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "taskManagement",
  components: { aTitle, Treeselect },
  data () {
    return {
      manualPreviewUrl: null,
      openPreview: false,
      isSumbit: true,
      loading: true,
      multiple: true,
      dialogVisible: false,
      title: '添加任务管理',
      multipleSelection: [],
      queryParams: {
        name: undefined,
        milestoneFlag: undefined,
        status: undefined,
        nickName: undefined,
        joinByName: undefined,
        planStartTime: undefined,
        actualStartTime: undefined,
        planEndTime: undefined,
        actualEndTime: undefined,
        businessId: undefined
      },
      taskOptionsChild: [],
      tableData: [],
      task: {
        taskParentId: null,
        name: "",
        milestoneFlag: "1",
        status: "0",
        planStartTime: "",
        actualStartTime: "",
        planEndTime: "",
        actualEndTime: "",
        nickName: "",
        joinByName: "",
        remark: "",
        joinBy: "",
        executeBy: ""
      },
      userList: [],
      taskTemplateList: [],
      formTemplateQuery: {
        pageNum: 1,
        pageSize: 10,
        templateName: undefined,
        businessCategoryId: undefined
      },
      openTemplate: false, // 模板弹框
      total: 0,
      tableAllLength: 0,
      canClick: false,
    };
  },
  created () {
    this.queryParams.businessId = this.$route.params.id;
    this.formTemplateQuery.businessCategoryId = this.$route.params.businessCategoryId;
    listAllMember({ projectId: this.$route.params.projectId, businessId: this.$route.params.id }).then(res => {
      this.userList = res.rows;
    });
    this.getList();
    this.treeTask();
    this.getTemplateList();
  },
  mounted(){
    document.title=document.getElementById("businessNameTitle").innerHTML;
  },
  methods: {
    preview () {
      this.openPreview = true;
      this.manualPreviewUrl = `${this.previewUrl}${encodeURIComponent(
        `${this.operationManual}业务主页/任务管理.xlsx`
      )}&name=${encodeURIComponent("任务管理.xlsx")}`;
    },
    getList () {
      this.loading = true;
      let params = {
        name: this.queryParams.name,
        milestoneFlag: this.queryParams.milestoneFlag,
        status: this.queryParams.status,
        nickName: this.queryParams.nickName,
        joinByName: this.queryParams.joinByName,
        businessId: this.queryParams.businessId
      };

      //actualStartDateStart
      if (this.queryParams.planStartTime) {
        params.planStartDateStart = this.queryParams.planStartTime[0];
        params.planStartDateEnd = this.queryParams.planStartTime[1];
        //params.planStartTime = undefined;
      }
      if (this.queryParams.actualStartTime) {
        params.actualStartDateStart = this.queryParams.actualStartTime[0];
        params.actualStartDateEnd = this.queryParams.actualStartTime[1];
        //params.actualStartTime = undefined;
      }
      if (this.queryParams.planEndTime) {
        params.planEndDateStart = this.queryParams.planEndTime[0];
        params.planEndDateEnd = this.queryParams.planEndTime[1];
        //params.planEndTime = undefined;
      }
      if (this.queryParams.actualEndTime) {
        params.actualEndDateStart = this.queryParams.actualEndTime[0];
        params.actualEndDateEnd = this.queryParams.actualEndTime[1];
        //params.actualEndTime = undefined;
      }

      listTask(params).then(response => {
        if (response.code === 200) {
          this.tableAllLength = response.data.length;
          this.tableData = this.handleTreeString(
            response.data,
            "guid",
            "taskParentId"
          );
          this.loading = false;
          this.treeTask();
        }
        //this.getTreeselect();
      });
    },
    treeTask () {
      var params = {
        businessId: this.$route.params.id
      };
      treeTask(params).then(res => {
        if (res.code === 200) {
          this.taskOptionsChild = [];
          const task = { id: "0", label: "主任务" };
          var taskChildren = this.handleTreeString(res.data, "id");
          if(taskChildren && taskChildren.length>0){
            task.children = taskChildren;
          }
          
          this.taskOptionsChild.push(task);
        }
      });
    },
    selectTask (node, instanceId) {
      this.task.taskParentId = node.label;
      this.task.name = node.label;
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.getList();
    },
    /*重置按钮操作 */
    resetQuery () {
      (this.queryParams = {
        name: undefined,
        milestoneFlag: undefined,
        status: undefined,
        nickName: undefined,
        joinByName: undefined,
        planStartTime: undefined,
        actualStartTime: undefined,
        planEndTime: undefined,
        actualEndTime: undefined,
        businessId: this.$route.params.id
      }),
        this.handleQuery();
    },
    handleEdit (index, row) {
      this.title = '编辑任务管理'
      getTask(row.guid).then(res => {
        if (res.code === 200) {
          if (res.data && res.data.joinBy) {
            res.data.joinBy = res.data.joinBy.split(",");
          }
          this.task = res.data;
          this.dialogVisible = true;
          this.isSumbit = false;
        }
      });
    },
    sumbitTask () {
      if (this.task.taskParentId === null) {
        this.msgError("主任务不能为空");
        return false;
      }
      if (this.task.name === null || this.task.name.trim() === "") {
        this.msgError("任务名称不能为空");
        return false;
      }
      var reqParams = {
        taskParentId: this.task.taskParentId,
        name: this.task.name,
        milestoneFlag: this.task.milestoneFlag,
        status: this.task.status,
        planStartTime: this.task.planStartTime,
        actualStartTime: this.task.actualStartTime,
        planEndTime: this.task.planEndTime,
        actualEndTime: this.task.actualEndTime,
        executeBy: this.task.executeBy,
        remark: this.task.remark,
        guid: this.task.guid
      };
      if (this.task.joinBy) {
        reqParams.joinBy = this.task.joinBy.join(",");
      }

      if (this.isSumbit) {
        this.canClick = true;
        reqParams.businessId = this.$route.params.id;
        addTask(reqParams).then(res => {
          if (res.code === 200) {
            this.getList();
            this.dialogVisible = false;
            this.msgSuccess(res.msg);
            this.treeTask();
          }
          this.canClick = false;
        });
      } else {
        updateTask(reqParams).then(res => {
          if (res.code === 200) {
            this.getList();
            this.dialogVisible = false;
            this.msgSuccess(res.msg);
          }
        });
      }
    },
    handleSelectionChange (val) {
      if (val.length) {
        val.map(item => {
          if (item.children.length > 0) {
            // 判断是否有子数据，有的话要进行循环
            this.selectAll(item.children, this.isAllSelect);
          }
        })
      }
      this.multipleSelection = val;
      this.multiple = !val.length;
    },
    changeDate (index, row) {
      this.loading = true;
      updateTask(row).then(res => {
        if (res.code === 200) {
          this.loading = false;
          this.msgSuccess(res.msg);
        }
      });
    },
    delete () {
      let delId = this.multipleSelection.map(item => {
        return item.guid;
      });
      let name = this.multipleSelection.map(item => {
        return item.name;
      });
      this.$confirm("是否确定删除任务名称为"+ name +"的任务？", "提示", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        delTask(delId).then(res => {
          if (res.code === 200) {
            this.getList();
            this.msgSuccess(res.msg);
          }
        });
      });
    },
    handleDelete () {
      //全部删除
      if (this.multipleSelection.length === this.tableAllLength) {
        this.delete();
      } else {
        var counts = this.task.length;
        let isDelete = this.multipleSelection.some(item => {
          if (item.children.length) {
            return true;
          }
        });
        if (isDelete) {
          this.$message({
            message: "有子任务,禁止删除！",
            type: "warning"
          });
        } else {
          this.delete();
        }
      }
    },
    handleAdd () {
      this.title = '添加任务管理'
      Object.keys(this.task).forEach(key => (this.task[key] = ""));
      this.task.taskParentId = null;
      this.task.milestoneFlag = "0";
      this.task.status = "0";
      this.dialogVisible = true;
      this.isSumbit = true;
      this.canClick = false;
    },
    // 获取模板列表
    getTemplateList () {
      this.loading = true;
      listTaskTemplate(this.formTemplateQuery).then(response => {
        this.taskTemplateList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleQueryTemp () {
      this.formTemplateQuery.pageNum = 1;
      this.getTemplateList();
    },
    resetQueryTemp () {
      this.formTemplateQuery.templateName = undefined;
      this.handleQueryTemp();
    },
    templateImport (row) {
      this.resetQuery();
      if (this.tableData.length) {
        this.$message({
          message: "已有任务存在，请清空任务后再导入标准模版!",
          type: "warning"
        });
        return false;
      } else {
        importTemplate(row.guid, this.$route.params.id).then(res => {
          if (res.code === 200) {
            this.msgSuccess(res.msg);
            this.getList();
          }
        });
      }
    },
    templatePreview (row) {
      this.filePreview(
        row.attachmentList[0].fileName,
        row.attachmentList[0].storagePath
      );
    },
    handleCommand (command) {
      if (command === "a") {
        this.openTemplate = true;
      }
    },
    beforeUpload (file) {
      let formData = new FormData();
      formData.append("file", file);
      formData.append("businessId", this.$route.params.id);
      if (
        file.name.split(".")[1] === "xlsx" ||
        file.name.split(".")[1] === "xls"
      ) {
        importData(formData).then(res => {
          this.msgSuccess("导入成功");
          this.$router.go(0);
        });
      } else {
        this.msgError("文件格式不正确");
      }
    },
    handleExport () {
      this.$confirm(
        "为避免导入时出错，自制模板仅供导入时使用，请勿修改！",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      ).then(() => {
        let params = {
          name: this.queryParams.name,
          milestoneFlag: this.queryParams.milestoneFlag,
          status: this.queryParams.status,
          nickName: this.queryParams.nickName,
          joinByName: this.queryParams.joinByName,
          businessId: this.queryParams.businessId
        };

        //actualStartDateStart
        if (this.queryParams.planStartTime) {
          params.planStartDateStart = this.queryParams.planStartTime[0];
          params.planStartDateEnd = this.queryParams.planStartTime[1];
          //params.planStartTime = undefined;
        }
        if (this.queryParams.actualStartTime) {
          params.actualStartDateStart = this.queryParams.actualStartTime[0];
          params.actualStartDateEnd = this.queryParams.actualStartTime[1];
          //params.actualStartTime = undefined;
        }
        if (this.queryParams.planEndTime) {
          params.planEndDateStart = this.queryParams.planStartTime[0];
          params.planEndDateEnd = this.queryParams.planStartTime[1];
          //params.planEndTime = undefined;
        }
        if (this.queryParams.actualEndTime) {
          params.actualEndDateStart = this.queryParams.actualEndTime[0];
          params.actualEndDateEnd = this.queryParams.actualEndTime[1];
          //params.actualEndTime = undefined;
        }
        exportTask(params).then(res => {
          if (res.code === 200) {
            this.download(res.msg);
          }
        });
      });
    },
    selectAll (selection, first) {
      if (!first) {
        // 判断是不是第一次进来，第一次进来要把this.isAllSelect设置为true或false，子数据循环就不需要
        this.isAllSelect = !this.isAllSelect;
      }
      selection.map(el => {
        if (el.children) {
          el.children.map(j => {
            this.toggleSelection(j, this.isAllSelect);
          });
          if (el.children.length > 0) {
            // 判断是否有子数据，有的话要进行循环
            this.selectAll(el.children, this.isAllSelect);
          } else {
            this.$nextTick(() => {
              this.$refs.multipleTable &&
                this.$refs.multipleTable.toggleRowSelection(el, this.isAllSelect);
            });
          }
        }
      });
    },

    toggleSelection (row, select) {
      // 切换选择，select为true就是选择，false为不选
      if (row) {
        this.$nextTick(() => {
          this.$refs.multipleTable &&
            this.$refs.multipleTable.toggleRowSelection(row, select);
        });
      }
    }
  }
};
</script>
<style lang="scss">
.el-table__row.expanded{
   td:nth-child(2){
     padding-left: 23px;
   }
 }

 .el-table__row--level-0{
    td:nth-child(2){
      padding-left: 0px !important;
   }
 }

 .el-table__row--level-1{
   td:nth-child(2){
      padding-left: 10px !important;
   }
 }

  .el-table__row--level-2{
   td:nth-child(2){
      padding-left: 10px !important;
   }
 }
  .el-table__row--level-3{
   td:nth-child(2){
      padding-left: 10px !important;
   }
 }
  .el-table__row--level-4{
   td:nth-child(2){
      padding-left: 10px !important;
   }
 }
  .el-table__row--level-5{
   td:nth-child(2){
      padding-left: 10px !important;
   }
 }
  .el-table__row--level-6{
   td:nth-child(2){
      padding-left: 10px !important;
   }
 }
</style>
<style lang="scss" scoped>
.tabletitle {
  margin: 0 20px;
  .input-wrap {
    padding: 8px;
    display: flex;

    .input-label {
      min-width: 1em;
      max-width: 6em;
      color: rgba(0, 0, 0, 0.65);
      margin-right: 8px;
      display: flex;
      flex: 0 0 90px;
      margin-top: 5px;
    }

    .input-content {
      -webkit-box-flex: 1;
      flex-grow: 1;
      .el-select {
        width: 100%;
      }
    }
  }
}
.tablebox {
  height: 100%;
}
/*/deep/.el-table th .cell .el-checkbox__input{
    display: none !important; 
}*/
/deep/.el-table .cell {
  font-family: PingFangSC-Regular;
  color: rgba(0, 0, 0, 0.85);
  letter-spacing: 0;
  a {
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #1890ff;
    letter-spacing: 0;
    text-align: right;
    line-height: 14px;
    margin: 0 10px;
  }
  .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }
}

.el-pagination {
  float: right;
  margin-top: 10px;
}
</style>